home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: November 18, 1996
- //
- // Description:
- // Duplicate option box script.
- //
-
- //
- // Procedure Name:
- // setOptionVars
- //
- // Description:
- // Initialize the option values.
- //
- // Input Arguments:
- // Whether to set the options to default values.
- //
- // Return Value:
- // None.
- //
- proc setOptionVars (int $forceFactorySettings)
- {
- // Rename Children flag
- //
- if ($forceFactorySettings || !`optionVar -exists duplicateRenameChildren`) {
- optionVar -intValue duplicateRenameChildren false;
- }
-
- // Smart transform flag
- //
- if ($forceFactorySettings || !`optionVar -exists duplicateSmart`) {
- optionVar -intValue duplicateSmart false;
- }
-
- // Number of duplicates
- //
- if ($forceFactorySettings || !`optionVar -exists duplicateCount`) {
- optionVar -intValue duplicateCount 1;
- }
-
- // Copy flag
- //
- if ($forceFactorySettings || !`optionVar -exists duplicateCopy`) {
- optionVar -intValue duplicateCopy true;
- }
-
- // Group flag
- //
- if ($forceFactorySettings || !`optionVar -exists duplicateGroup`) {
- optionVar -intValue duplicateGroup 1;
- }
-
- // Duplicate upstream nodes flag
- //
- if ($forceFactorySettings || !`optionVar -exists duplicateUpstream`) {
- optionVar -intValue duplicateUpstream false;
- }
-
- // Duplicate input Connections flag
- //
- if ($forceFactorySettings || !`optionVar -exists duplicateInputConn`) {
- optionVar -intValue duplicateInputConn false;
- }
-
- // Translate values
- //
- if ($forceFactorySettings || !`optionVar -exists duplicateTX`) {
- optionVar -floatValue duplicateTX 0.0;
- }
- if ($forceFactorySettings || !`optionVar -exists duplicateTY`) {
- optionVar -floatValue duplicateTY 0.0;
- }
- if ($forceFactorySettings || !`optionVar -exists duplicateTZ`) {
- optionVar -floatValue duplicateTZ 0.0;
- }
-
- // Rotate values
- //
- if ($forceFactorySettings || !`optionVar -exists duplicateRX`) {
- optionVar -floatValue duplicateRX 0.0;
- }
- if ($forceFactorySettings || !`optionVar -exists duplicateRY`) {
- optionVar -floatValue duplicateRY 0.0;
- }
- if ($forceFactorySettings || !`optionVar -exists duplicateRZ`) {
- optionVar -floatValue duplicateRZ 0.0;
- }
-
- // Scale values
- //
- if ($forceFactorySettings || !`optionVar -exists duplicateSX`) {
- optionVar -floatValue duplicateSX 1.0;
- }
- if ($forceFactorySettings || !`optionVar -exists duplicateSY`) {
- optionVar -floatValue duplicateSY 1.0;
- }
- if ($forceFactorySettings || !`optionVar -exists duplicateSZ`) {
- optionVar -floatValue duplicateSZ 1.0;
- }
- }
-
- //
- // Procedure Name:
- // duplicateSetup
- //
- // Description:
- // Update the state of the option box UI to reflect the option values.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI.
- // Required so that UI object names can be
- // successfully resolved.
- //
- // forceFactorySettings - Whether the option values should be set to
- // default values.
- //
- // Return Value:
- // None.
- //
- global proc duplicateSetup (string $parent, int $forceFactorySettings)
- {
- // Retrieve the option settings
- //
- setOptionVars ($forceFactorySettings);
-
- setParent $parent;
-
- // Query the optionVar's and set the values into the controls.
- //
- int $renameChildren = `optionVar -q duplicateRenameChildren`;
- int $numDuplicates = `optionVar -q duplicateCount`;
- int $smart = `optionVar -q duplicateSmart`;
- int $copy = `optionVar -q duplicateCopy`;
- int $group = `optionVar -q duplicateGroup`;
- if ($group == 0) $group = 1; // Earlier boolean false should now map to 1
- int $upstream = `optionVar -q duplicateUpstream`;
- int $inputConn = `optionVar -q duplicateInputConn`;
-
- // Rename Children flag
- //
- checkBoxGrp -edit -value1 $renameChildren renameChildrenField;
-
- // Number of duplicates
- //
- intSliderGrp -e -v $numDuplicates numDuplicatesField;
-
- // Smart transform flag
- //
- checkBoxGrp -edit -value1 $smart smartCheck;
-
- // Copy flag
- //
- int $boolToOption[] = { 2, 1 };
- radioButtonGrp -edit -select $boolToOption[$copy]
- geometryTypeGroup;
-
- // Group flag
- //
- radioButtonGrp -e -select $group otherOptionsGroup;
-
- // Duplicate upstream nodes flag
- //
- checkBoxGrp -edit -value1 $upstream upstreamCheck;
-
- // Duplicate input Connections flag
- //
- checkBoxGrp -edit -value1 $inputConn inputConnCheck;
-
- // Translate values
- //
- float $tx = `optionVar -q duplicateTX`;
- float $ty = `optionVar -q duplicateTY`;
- float $tz = `optionVar -q duplicateTZ`;
- floatFieldGrp -edit -value1 $tx -value2 $ty -value3 $tz transField;
-
- // Rotate values
- //
- float $rx = `optionVar -q duplicateRX`;
- float $ry = `optionVar -q duplicateRY`;
- float $rz = `optionVar -q duplicateRZ`;
- floatFieldGrp -edit -value1 $rx -value2 $ry -value3 $rz rotateField;
-
- // Scale values
- //
- float $sx = `optionVar -q duplicateSX`;
- float $sy = `optionVar -q duplicateSY`;
- float $sz = `optionVar -q duplicateSZ`;
- floatFieldGrp -edit -value1 $sx -value2 $sy -value3 $sz scaleField;
-
- duplicateOptionsUpdateEnableState($parent);
- }
-
- global proc duplicateOptionsUpdateEnableState(string $parent)
- //
- // Description:
- // Update the enable state of all the option box controls.
- //
- // Call this whenever any of the control values changes.
- //
- {
- int $smartTransform;
- int $makeInstance;
- int $groupParent;
- int $simpleCopy;
- int $upstreamGraph;
- int $inputConnections;
- int $numberOfDuplicates;
- int $enableSmartTransform;
- int $enableTRSFields;
-
- setParent $parent;
-
- // Determine the number of duplicates.
- //
- $numberOfDuplicates = `intSliderGrp -query -value numDuplicatesField`;
-
- // Determine if smart transform is on.
- //
- $smartTransform = `checkBoxGrp -query -value1 smartCheck`;
-
- // Determine if copying geometry or making instance.
- //
- $copyGeometry = true;
- if (2 == `radioButtonGrp -query -select geometryTypeGroup`) {
- $copyGeometry = false;
- }
-
- // Determine if duplicate is to be under the parent.
- //
- $groupParent = false;
- if (1 == `radioButtonGrp -query -select otherOptionsGroup`) {
- $groupParent = true;
- }
-
- // Determine if settings describe a simple copy, ie. no duplication
- // of Upstream graph or Input connections.
- //
- $simpleCopy = true;
- $upstreamGraph = `checkBoxGrp -query -value1 upstreamCheck`;
- $inputConnections = `checkBoxGrp -query -value1 inputConnCheck`;
- if ($upstreamGraph || $inputConnections) {
- $simpleCopy = false;
- }
-
- // Enable Smart Transform check box...
- //
- $enableSmartTransform = false;
- if (1 == $numberOfDuplicates && $groupParent && $simpleCopy) {
- $enableSmartTransform = true;
- }
- checkBoxGrp -edit -enable $enableSmartTransform smartCheck;
-
- // Enable Translate, rotate and scale fields...
- //
- $enableTRSFields = false;
- if (!$smartTransform && $simpleCopy) {
- $enableTRSFields = true;
- }
- floatFieldGrp -edit -enable $enableTRSFields transField;
- floatFieldGrp -edit -enable $enableTRSFields rotateField;
- floatFieldGrp -edit -enable $enableTRSFields scaleField;
-
- // Enable Upstream Graph and Input Connection check boxes...
- //
- checkBoxGrp -edit -enable ($copyGeometry && !$inputConnections) upstreamCheck;
- checkBoxGrp -edit -enable ($copyGeometry && !$upstreamGraph) inputConnCheck;
-
- // Enable Geometry Type radio button...
- //
- radioButtonGrp -edit -enable $simpleCopy geometryTypeGroup;
- }
-
- //
- // Procedure Name:
- // duplicateCallback
- //
- // Description:
- // Update the option values with the current state of the option box UI.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI. Required so
- // that UI object names can be successfully resolved.
- //
- // doIt - Whether the command should execute.
- //
- // Return Value:
- // None.
- //
- global proc duplicateCallback (string $parent, int $doIt)
- {
- setParent $parent;
-
- // Set the optionVar's from the control values, and then
- // perform the command
-
- // Smart transform flag
- //
- optionVar -intValue duplicateSmart
- `checkBoxGrp -q -v1 smartCheck`;
-
- // Rename Children flag
- //
- optionVar -intValue duplicateRenameChildren
- `checkBoxGrp -q -v1 renameChildrenField`;
-
- // Number of duplicates
- //
- optionVar -intValue duplicateCount
- `intSliderGrp -q -v numDuplicatesField`;
-
- // Instance flag
- //
- int $optionToBool[] = { 0, true, false };
- int $i = `radioButtonGrp -q -select geometryTypeGroup`;
- optionVar -intValue duplicateCopy $optionToBool[$i];
-
- // Group flag
- //
- optionVar -intValue duplicateGroup
- `radioButtonGrp -q -select otherOptionsGroup`;
-
- // Duplicate upstream nodes flag
- //
- optionVar -intValue duplicateUpstream
- `checkBoxGrp -q -v1 upstreamCheck`;
-
- // Duplicate input Connections flag
- //
- optionVar -intValue duplicateInputConn
- `checkBoxGrp -q -v1 inputConnCheck`;
-
- // Translate values
- //
- optionVar -floatValue duplicateTX
- `floatFieldGrp -q -v1 transField`;
- optionVar -floatValue duplicateTY
- `floatFieldGrp -q -v2 transField`;
- optionVar -floatValue duplicateTZ
- `floatFieldGrp -q -v3 transField`;
-
- // Rotate values
- //
- optionVar -floatValue duplicateRX
- `floatFieldGrp -q -v1 rotateField`;
- optionVar -floatValue duplicateRY
- `floatFieldGrp -q -v2 rotateField`;
- optionVar -floatValue duplicateRZ
- `floatFieldGrp -q -v3 rotateField`;
-
- // Scale values
- //
- optionVar -floatValue duplicateSX
- `floatFieldGrp -q -v1 scaleField`;
- optionVar -floatValue duplicateSY
- `floatFieldGrp -q -v2 scaleField`;
- optionVar -floatValue duplicateSZ
- `floatFieldGrp -q -v3 scaleField`;
-
- if ($doIt) {
- performDuplicate 0;
- addToRecentCommandQueue "performDuplicate 0" "Duplicate";
- }
- }
-
- //
- // Procedure Name:
- // duplicateOptions
- //
- // Description:
- // Construct the option box UI. Involves accessing the standard option
- // box and customizing the UI accordingly.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
- proc duplicateOptions ()
- {
- // Name of the command for this option box.
- //
- string $cmdName = "duplicate";
-
- // Build the option box actions.
- //
- string $callback = ($cmdName + "Callback");
- string $setup = ($cmdName + "Setup");
-
- // STEP 1: Get the option box.
- // ============================
- //
- // The value returned is the name of the layout to be used as
- // the parent for the option box UI.
- //
- string $layout = getOptionBox();
- setParent $layout;
-
- // STEP 2: Pass the command name to the option box.
- // =================================================
- //
- // Any default option box behaviour based on the command name is set
- // up with this call. For example, updating the 'Help' menu item with
- // the name of the command.
- //
- setOptionBoxCommandName($cmdName);
-
- // STEP 3: Activate the default UI template.
- // ==========================================
- //
- // Activate the default UI template so that the layout of this
- // option box is consistent with the layout of the rest of the
- // application.
- //
- setUITemplate -pushTemplate DefaultTemplate;
-
- // Turn on the wait cursor.
- //
- waitCursor -state 1;
-
- // STEP 4: Create option box contents.
- // ===================================
- //
- tabLayout -scr true -tv false;
- string $parent = `columnLayout -adjustableColumn 1`;
-
- floatFieldGrp -label "Translate"
- -numberOfFields 3
- transField;
-
- floatFieldGrp -label "Rotate"
- -numberOfFields 3
- rotateField;
-
- floatFieldGrp -label "Scale"
- -numberOfFields 3
- scaleField;
-
- intSliderGrp -label "Number of Copies"
- -field true
- -minValue 1
- -maxValue 100
- -fieldMaxValue 1000
- -changeCommand ("duplicateOptionsUpdateEnableState " + $parent)
- numDuplicatesField;
-
- separator -style "in";
-
- radioButtonGrp
- -label "Geometry Type"
- -numberOfRadioButtons 2 -label1 "Copy" -label2 "Instance"
- -changeCommand ("duplicateOptionsUpdateEnableState " + $parent)
- geometryTypeGroup;
-
- radioButtonGrp -numberOfRadioButtons 3 -label "Group under"
- -label1 "Parent"
- -label2 "World"
- -label3 "New Group"
- -changeCommand ("duplicateOptionsUpdateEnableState " + $parent)
- otherOptionsGroup;
-
- checkBoxGrp -numberOfCheckBoxes 1
- -label1 "Smart Transform"
- -changeCommand ("duplicateOptionsUpdateEnableState " + $parent)
- smartCheck;
-
- separator -style "in";
-
- checkBoxGrp
- -numberOfCheckBoxes 1
- -label1 "Duplicate Input Graph"
- -changeCommand ("duplicateOptionsUpdateEnableState " + $parent)
- upstreamCheck;
-
- checkBoxGrp
- -numberOfCheckBoxes 1
- -label1 "Duplicate Input Connections"
- -changeCommand ("duplicateOptionsUpdateEnableState " + $parent)
- inputConnCheck;
-
- separator -style "in";
-
- checkBoxGrp
- -numberOfCheckBoxes 1
- -label1 "Assign Unique Name to Child Nodes"
- -value1 0
- renameChildrenField;
-
- // Turn off the wait cursor.
- //
- waitCursor -state 0;
-
- // Step 5: Deactivate the default UI template.
- // ===========================================
- //
- setUITemplate -popTemplate;
-
- // Step 6: Customize the buttons.
- // ==============================
- //
- // Provide more descriptive labels for the buttons.
- // Disable those buttons that are not applicable to the option box.
- // Attach actions to those buttons that are applicable to the option
- // box.
-
- // 'Apply' button.
- //
- string $applyBtn = getOptionBoxApplyBtn();
- button -edit
- -label "Duplicate"
- -command ($callback + " " + $parent + " " + 1)
- $applyBtn;
-
- // 'Save' button.
- //
- string $saveBtn = getOptionBoxSaveBtn();
- button -edit
- -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
- $saveBtn;
-
- // 'Reset' button.
- //
- string $resetBtn = getOptionBoxResetBtn();
- button -edit
- -command ($setup + " " + $parent + " " + 1)
- $resetBtn;
-
- // Set the option box title.
- // =========================
- //
- setOptionBoxTitle("Duplicate Options");
-
- // Customize the 'Help' menu item text.
- //
- setOptionBoxHelpTag( "Duplicate" );
-
- // Set the current values of the option box.
- // =========================================
- //
- eval (($setup + " " + $parent + " " + 0));
-
- // Show the option box.
- // ====================
- //
- showOptionBox();
- }
-
- //
- // Procedure Name:
- // duplicateHelp
- //
- // Description:
- // Return a short description about this command.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // string.
- //
- proc string duplicateHelp()
- {
- return
- " Command: Duplicate - create a copy of selected objects.\n" +
- "Selection: objects.";
- }
-
- //
- // Procedure Name:
- // assembleCmd
- //
- // Description:
- // Construct the command that will apply the option box values.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
- proc string assembleCmd()
- {
- string $cmd = "duplicatePreset";
-
- setOptionVars(false);
-
- int $count = `optionVar -q duplicateCount`;
- int $copy = `optionVar -q duplicateCopy`;
- int $group = `optionVar -q duplicateGroup`;
- int $smart = `optionVar -q duplicateSmart`;
- int $upstream = `optionVar -q duplicateUpstream`;
- int $inputConn = `optionVar -q duplicateInputConn`;
- int $renameChild = `optionVar -q duplicateRenameChildren`;
-
- float $transX = `optionVar -q duplicateTX`;
- float $transY = `optionVar -q duplicateTY`;
- float $transZ = `optionVar -q duplicateTZ`;
-
- float $rotatX = `optionVar -q duplicateRX`;
- float $rotatY = `optionVar -q duplicateRY`;
- float $rotatZ = `optionVar -q duplicateRZ`;
-
- float $scaleX = `optionVar -q duplicateSX`;
- float $scaleY = `optionVar -q duplicateSY`;
- float $scaleZ = `optionVar -q duplicateSZ`;
-
- $cmd = ($cmd + "("
- + $count + ","
- + $copy + ","
- + $group + ","
- + $smart + ","
- + $upstream + ","
- + $inputConn + ","
- + $renameChild + ","
-
- + $transX + ","
- + $transY + ","
- + $transZ + ","
-
- + $rotatX + ","
- + $rotatY + ","
- + $rotatZ + ","
-
- + $scaleX + ","
- + $scaleY + ","
- + $scaleZ + ")"
- );
-
- return $cmd;
- }
-
- //
- // Procedure Name:
- // performDuplicate
- //
- // Description:
- // Perform the duplicate command using the corresponding
- // option values. This procedure will also show the option box
- // window if necessary as well as construct the command string
- // that will invoke the duplicate command with the current
- // option box values.
- //
- // Input Arguments:
- // 0 - Execute the command.
- // 1 - Show the option box dialog.
- // 2 - Return the command.
- //
- global proc string performDuplicate (int $action)
- {
- string $cmd = "";
-
- switch ($action) {
-
- // Execute the command.
- //
- case 0:
- // Get the command.
- //
- $cmd = `assembleCmd`;
-
- // Execute the command with the option settings.
- //
- // *NOTE* we do NOT want to use evalEcho here because
- // this calls the duplicatePreset command which does
- // the command echoing.
- //
- eval($cmd);
-
- break;
-
- // Show the option box.
- //
- case 1:
- duplicateOptions();
- break;
-
- // Return the command string.
- //
- case 2:
- // Get the command.
- //
- $cmd = `assembleCmd`;
- break;
- }
- return $cmd;
- }
-
-